const path = require('path')

const HtmlWebpackPlugin=require('html-webpack-plugin')
module.exports = {
  entry: './src/main.js', // 入口, 可以为相对路径, 当然绝对路径也没错
  output: { // 输出配置
    path: path.join(__dirname, './dist'), // 输出的目录
    filename: './js/[name].[hash:8].bundle.js', // 输出的文件名
    clean:true,
  },
  mode: 'development', // 打包的模式, production | development
  plugins:[
    new HtmlWebpackPlugin({
        template:'./src/index.html',
        filename:'./index.html',
        inject:"body"
    })
],
  module: {
    rules: [
        {
            test: /.js$/,
            exclude: /node_modules/,
            use: {
                loader: 'babel-loader',
            }
        },
        {
          test: /\.ts$/,    
          use: 'ts-loader',
          exclude: /node-modules/
        }
    ]
},
devServer:{
    open:true,
    hot:true,
    watchFiles:["./src/index.html"]
}

}

